// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueRouter from 'vue-router'
import iView from 'iview';
import 'iview/dist/styles/iview.css';    // 使用 CSS

import axios from 'axios'

axios.interceptors.request.use(
    (config) => {
        config.headers['Access-Control-Allow-Origin'] = ''
        config.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization, X-CodePush-Plugin-Version, X-CodePush-Plugin-Name, X-CodePush-SDK-Version'
        config.headers['Access-Control-Allow-Methods'] = 'PUT,POST,GET,PATCH,DELETE,OPTIONS'
        return config;
    },
    (err) => {
        Message.error("请求超时");
        return Promise.resolve(err);
    }
);

Vue.prototype.$axios = axios

Vue.use(iView);
Vue.use(VueRouter)

Vue.config.productionTip = false

let development = process.env.NODE_ENV == 'development' ? true : false;

if (development) {
    axios.defaults.baseURL = '/api'
}

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
})
